<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        $.ajax({
            url: that.SEMCShareApiUrl + "report/downloadYearReport",
            type: "post",
            contentType: "text/plain",
            xhrFields: {
                responseType: "blob",
            },
            data: str,
            success: function (res, status, xhr) {
                // console.log(res);
                var disposition = xhr.getResponseHeader("Content-Disposition");
                const filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
                const matches = filenameRegex.exec(disposition);
                const filename =
                    matches != null && matches[1]
                        ? matches[1].replace(/['"]/g, "")
                        : "上海市排放源统计年报技术分析报告";
                // console.log(filename);
                // console.log(decodeURI(filename),'111');
                const link = document.createElement("a");
                let blob = new Blob([res], {
                    type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
                });
                link.style.display = "none";
                link.href = URL.createObjectURL(blob);
                document.body.appendChild(link);
                link.download =
                    decodeURI(filename) || "上海市排放源统计年报技术分析报告";
                // link.download=filename
                link.click();
                document.body.removeChild(link);
                that.loading = false;
            },
            error: function (error) {
                // console.log(error);
                that.$message({
                    message: "请求错误！",
                    type: "error",
                    offset: (document.body.clientHeight - 60) / 2,
                });
                that.loading = false;
            },
            beforeSend: function (xhr) {
                xhr.setRequestHeader("Access-Control-Allow-Origin", "*");
                xhr.withCredentials = true;
            },
        });
    </script>
</body>

</html>